package com.david.appletree

import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.util.Log
import android.widget.Toast

/**
 * 可通过显示发送广播方式接收到广播：
 * intent.setComponent(ComponentName("com.david.appletree", "com.david.appletree.TestBroadCast"))
 * sendBroadcast(intent)
 * */
public class TestBroadCast: BroadcastReceiver() {
    override fun onReceive(context: Context?, intent: Intent?) {
        if (intent != null) {
            Log.e("TestBroadCast", "action is :" + intent.action)
        } else {
            Log.e("TestBroadCast", "onReceive.....")

        }
        if (context != null) {
            Toast.makeText(context, "TestBroadCast onReceive...", 1).show()
        }
    }
}